review_interval <- function(sample1, sample2, fac = 3, alpha = 0.05) {
# browser()
crit <- qchisq(1 - alpha, 1)
phat1 <- calculate_mles(sample1)$phat
phat2 <- calculate_mles(sample2)$phat
gamhat <- log((phat1 * (1 - phat2)) / (phat2 * (1 - phat1)))
num <- likelihood_gam(gamhat, sample1, sample2)
gs <- seq(gamhat - crit, gamhat + fac * crit, length.out = 50)
vals <- sapply(gs, function(.) likelihood_gam(., sample1, sample2))
ratio_vals <- 2 * log(num / vals) - crit
list(
sample_one = sample1,
sample_two = sample2,
mles = c(
"phat1" = phat1,
"phat2" = phat2,
"gamhat" = gamhat,
"numerator" = num
),
gamma_vals = gs,
denominator_likelihood_vals = vals,
ratio_vals = ratio_vals,
plot = {
qplot(gs, ratio_vals, geom = "path") +
geom_hline(yintercept = 0, linetype = "dotted") +
geom_vline(xintercept = gamhat, linetype = "dashed")
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.